package my.cloud.study.controller;

import my.cloud.study.User;
import my.cloud.study.service.HelloRemoteService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RefreshScope
public class HelloController {

    @Autowired
    private HelloRemoteService helloRemoteService;

    @Value("${cloud.test.description}")
    private String description;

    @GetMapping("/usr")
    public User user(){
        User user = helloRemoteService.userInfo();
        user.setDescription(description);
        return user;
    }

    @GetMapping("info/{id}")
    public String info(@PathVariable("id") String id){
        return helloRemoteService.info(id);
    }
}
